package com.xmx.ndmallwxapi.feign.factory;


import com.xmx.common.utils.PageUtils;
import com.xmx.common.utils.R;
import com.xmx.ndmallwxapi.feign.ProductFeignClient;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @Date: 2021/8/11 11:30
 */
@Component
public class ProductFallbackFatory implements FallbackFactory<ProductFeignClient> {

    @Override
    public ProductFeignClient create(Throwable throwable) {
        return new ProductFeignClient() {
            public R listChannel(Map<String, Object> params) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R listBrand(Map<String, Object> params) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R listNewGoods(Map<String, Object> params) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R getFloorGoodsList() {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R count() {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R getBrandList(Integer brandId, Integer page, Integer limit) {
                return null;
            }

            @Override
            public R detail(Integer id) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R info(Integer id) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R listspecification(Integer id) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R listcomment(Integer id) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R listgoodattri(Integer id) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R getbrand(Integer id) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map) ;
            }

            @Override
            public R getBdlist(Integer page, Integer limit) {
                return null;
            }

            @Override
            public R listproduct(Integer id) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return R.ok(map);
            }

            @Override
            public PageUtils related(Integer id) {
                Map map = new HashMap();
                map.put("page","id:0000,msg:请求失败,error:"+ throwable.getMessage());
                return null;
            }

            @Override
            public R goodsproductinfo(Integer id) {
                return null;
            }

            @Override
            public Integer reduceStock(Integer id, Integer num) {
                return null;
            }

            @Override
            public Integer addStock(Integer id, Integer num) {
                return null;
            }

        };
    }
}
